﻿using B.S.Shop.Application.Command;
using B.S.Shop.Domain;
using B.S.Shop.ErrorCode;
using B.S.Shop.Infartructrue.Interfaces;
using MediatR;

namespace B.S.Shop.Application.Commandhandler
{
    public class OrderQueryCommandHandler : IRequestHandler<OrderQueryCommand, APIResult<List<OrderClass>>>
    {
        public OrderQueryCommandHandler(IBaseRepository<OrderClass> orderRepository)
        {
            OrderRepository = orderRepository;
        }

        public IBaseRepository<OrderClass> OrderRepository { get; }

        public async Task<APIResult<List<OrderClass>>> Handle(OrderQueryCommand request, CancellationToken cancellationToken)
        {
            var path = OrderRepository.GetAll().Where(a=>!a.isShow).ToList();
            return new APIResult<List<OrderClass>>
            {
                Code = ResultCode.success,
                Mag = "",
                data = path
            };
        }
    }
}
